package practice_bank;

/**
 * 取款线程类
 */
class WithdrawThread extends Thread {
    private JointAccount account;
    private double amount;
    private String name;
    private boolean useSafeMethod;

    public WithdrawThread(JointAccount account, double amount, String name, boolean useSafeMethod) {
        this.account = account;
        this.amount = amount;
        this.name = name;
        this.useSafeMethod = useSafeMethod;
    }

    @Override
    public void run() {
        if (useSafeMethod) {
            account.safeWithdraw(amount, name);
        } else {
            account.withdraw(amount, name);
        }
    }
}